﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TheVoiceOfSnake
{
    class HammingWindowHandler
    {
        private double a = 0.54; // optymalna wartość współczynnika opisana w literaturze
        private int N;

        public void Windowing(List<Frame> frames)
        {
            N = frames.First().Size();
            foreach (var frame in frames)
            {
                ComputeValues(frame);
            }
        }

        public void ComputeValues(Frame frame)
        {
            double factor;
            for (int i = 0; i < N; i++)
            {
                factor = a - (1 - a) * Math.Cos((2 * Math.PI * i) / (N - 1));
                frame[i] = frame[i] * factor;
            }
        }
    }
}
